package com.itcoon.transform.starter.handler;

import com.itcoon.transform.base.definition.InjectDefinition;
import com.itcoon.transform.starter.proxy.Transform4jCglibProxy;

import java.util.List;

/**
 * @author Miaoxia Yu
 * @date 2020-10-28
 */
public class ClazzTransformHandler implements TransformHandler {

    @Override
    public boolean supports(Class<?> targetClass) {
        return !targetClass.isInterface();
    }

    @Override
    public <T, R> R handle(Class<R> targetClass, T source, List<InjectDefinition.InjectInfo> injectInfos) {
        return new Transform4jCglibProxy<>(targetClass, source, injectInfos).instance();
    }
}
